<?php
class Aml_Controller_Plugin_Acl extends Zend_Controller_Plugin_Abstract
{
public function preDispatch(Zend_Controller_Request_Abstract $request)
{
$acl = Zend_Registry::get("acl");
$storage = new Zend_Auth_Storage_Session();
$userType=$storage->read()->admin_userType;
If($userType==""){
$roleName="guest";
} else {
$roleName=$userType;
}
$resourceName=$request->getControllerName();
$privilageName=$request->getActionName();
 $this->_db = Zend_Registry::get('db');
 $isACLconfigured=$this->_db->fetchAll("select *    from  aml_acl where role='".$roleName."' and component='".$resourceName."' and action='".$privilageName."' ");
 //print_r($isACLconfigured);exit;
if(!$acl->isAllowed($roleName,$resourceName,$privilageName) && $isACLconfigured){
$request->setControllerName("Error");
$request->setActionName("index");
}
}
}

?>
